package multiThread;

/* Multi thread Example with Bike Game
 * 
 * yield() - allow other threads of the same priority to run and suspend the current thread.
 * suspended()	suspend  the execution of the current thread.
 * 				This method is depreciated;  wait(), notify(), notifyAll() ...
 * 
 */

class Az implements Runnable {
	public void run() {
		for (int i = 0; i < 30; i++) {
			System.out.println(Thread.currentThread().getName() + " I = " + i);
			try {
				Thread.sleep(100);
			} catch (InterruptedException e) {
			}
		}
	}
}

class Bz implements Runnable {
	public void run() {
		Thread t = Thread.currentThread();
		String name = t.getName();
		for (int i = 0; i < 20; i++) {
			try {
				Thread.sleep(50);
			} catch (InterruptedException e) {
			}
			System.out.println(name + " J = " + i);
		}
	}

}

public class MyThread6 {
	public static void main(String args[]) {
		Az obj1 = new Az();
		Bz obj2 = new Bz();
		// Creation of thread.
		Thread t1 = new Thread(obj1);
		Thread t2 = new Thread(obj2);

		// Thread is made runnable.
		t1.start();
		t2.start();

		// Check for Thread alive
		System.out.println(t1.isAlive());
		System.out.println(t2.isAlive());
		System.out.println(Thread.currentThread().isAlive());
	}
}